package com.fr.plugin.export.xml.core;

import com.fr.general.DeclareRecordType;
import com.fr.plugin.export.xml.exporter.XmlExporter;
import com.fr.io.collection.ExportCollection;
import com.fr.stable.web.SessionProvider;
import com.fr.web.core.ReportSessionIDInfor;
import com.fr.web.core.reserve.DefaultOperate;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class XmlExportOperate extends DefaultOperate {
    public XmlExportOperate() {
    }

    public void setContent(HttpServletRequest req, HttpServletResponse res, String fileName, boolean isEmbed) {
        res.setContentType("application/octet-stream");
        res.setHeader("extension", "xml");
        res.setHeader("Content-disposition", "attachment; filename=" + fileName + ".xml");
    }

    @Override
    public ExportCollection createCollection(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, ReportSessionIDInfor reportSessionIDInfor, String s) {
        ExportCollection collection = ExportCollection.create();
        collection.setExporter(new XmlExporter());
        collection.setRecordType(DeclareRecordType.EXPORT_TYPE_CSV);
        return collection;
    }

    public void setContent(HttpServletRequest req, HttpServletResponse res, SessionProvider sessionProvider, String fileName, boolean isEmbed) {
        this.setContent(req, res, fileName, isEmbed);
    }

//    @Override
//    public ExportCollection newExportCollection(HttpServletRequest req, HttpServletResponse res, SessionProvider sessionIDInfor, String fileName) {
//        ExportCollection collection = ExportCollection.create();
//        collection.setExporter(new XmlExporter());
//        collection.setRecordType(ReportDeclareRecordType.EXPORT_TYPE_CSV);
//        return collection;
//    }

//    public ExportChecker newExportChecker(HttpServletRequest httpServletRequest) {
//        ExportChecker checker = new ExportChecker() {
//            @Override
//            public Set<String> checkFont(String s) {
//                return FontHelper.checkChartFont(s);
//            }
//        };
//        return null;
//    }

}